<?php
/**
 * Magento
 *
 * NOTICE OF LICENSE
 *
 * This source file is subject to the Academic Free License (AFL 3.0)
 * that is bundled with this package in the file LICENSE_AFL.txt.
 * It is also available through the world-wide-web at this URL:
 * http://opensource.org/licenses/afl-3.0.php
 * If you did not receive a copy of the license and are unable to
 * obtain it through the world-wide-web, please send an email
 * to license@magentocommerce.com so we can send you a copy immediately.
 *
 * DISCLAIMER
 *
 * Do not edit or add to this file if you wish to upgrade Magento to newer
 * versions in the future. If you wish to customize Magento for your
 * needs please refer to http://www.magentocommerce.com for more information.
 *
 * @copyright   Copyright (c) 2014 X.commerce, Inc. (http://www.magentocommerce.com)
 * @license     http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
 */
?>
<div class="block block-dashboard-orders">
<?php $_orders = $this->getOrders(); ?>
    <div class="block-title order">
        <strong><?php echo __('Recent Orders') ?></strong>
        <?php if( sizeof($_orders->getItems()) > 0 ): ?>
            <a class="action view" href="<?php echo $this->getUrl('sales/order/history') ?>">
                <span><?php echo __('View All') ?></span>
            </a>
        <?php endif; ?>
    </div>
    <div class="block-content">
    <?php echo $this->getChildHtml()?>
    <?php if( sizeof($_orders->getItems()) > 0 ): ?>
        <div class="table-wrapper orders-recent">
            <table class="data table table-order-items recent" id="my-orders-table">
                <caption class="table caption"><?php echo __('Recent Orders') ?></caption>
                <thead>
                    <tr>
                        <th scope="col" class="col id"><?php echo __('Order #') ?></th>
                        <th scope="col" class="col date"><?php echo __('Date') ?></th>
                        <th scope="col" class="col shipping"><?php echo __('Ship To') ?></th>
                        <th scope="col" class="col total"><?php echo __('Order Total') ?></th>
                        <th scope="col" class="col status"><?php echo __('Status') ?></th>
                        <th scope="col" class="col actions">&nbsp;</th>
                    </tr>
                </thead>
                <tbody>
                    <?php foreach ($_orders as $_order): ?>
                        <tr>
                            <td data-th="<?php echo $this->escapeHtml(__('Order #')) ?>" class="col id"><?php echo $_order->getRealOrderId() ?></td>
                            <td data-th="<?php echo $this->escapeHtml(__('Date')) ?>" class="col date"><?php echo $this->formatDate($_order->getCreatedAtStoreDate()) ?></td>
                            <td data-th="<?php echo $this->escapeHtml(__('Ship To')) ?>" class="col shipping"><?php echo $_order->getShippingAddress() ? $this->escapeHtml($_order->getShippingAddress()->getName()) : '&nbsp;' ?></td>
                            <td data-th="<?php echo $this->escapeHtml(__('Order Total')) ?>" class="col total"><?php echo $_order->formatPrice($_order->getGrandTotal()) ?></td>
                            <td data-th="<?php echo $this->escapeHtml(__('Status')) ?>" class="col status"><?php echo $_order->getStatusLabel() ?></td>
                            <td data-th="<?php echo $this->escapeHtml(__('Actions')) ?>" class="col actions">
                                <a href="<?php echo $this->getViewUrl($_order) ?>" class="action view">
                                    <span><?php echo __('View Order') ?></span>
                                </a>
                                <?php if ($this->helper('Magento\Sales\Helper\Reorder')->canReorder($_order)) : ?>
                                    <a href="<?php echo $this->getReorderUrl($_order) ?>" class="action order">
                                        <span><?php echo __('Reorder') ?></span>
                                    </a>
                                <?php endif ?>
                            </td>
                        </tr>
                    <?php endforeach; ?>
                </tbody>
            </table>
        </div>
    <?php else: ?>
        <div class="message info empty"><span><?php echo __('You have placed no orders.'); ?></span></div>
    <?php endif; ?>
    </div>
</div>
